package com.dc.service;

import com.dc.constant.Constants;
import com.dc.dao.*;
import com.dc.dao.vo.CalibrationShipCutReturnVO;
import com.dc.dao.vo.CalibrationShipOldReturnVO;
import com.dc.dao.vo.calibration_stat.CalibrationStat;
import com.dc.entity.*;
import com.dc.service.dto.*;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class CalibrationStatService {

    public static final String DATA = "rows";
    public static final String STAT = "stat";


    @Resource
    CalibrationService calibrationService;

    @Resource
    CalibrationShipCutDao shipCutDao;

    @Resource
    CalibrationShipOldDao shipOldDao;

    @Resource
    CalibrationShipWeldDao shipWeldDao;

    @Resource
    CalibrationMachinePipeDao machinePipeDao;

    @Resource
    CalibrationPaintHouseDao paintHouseDao;

    @Resource
    CalibrationPaintShipDao paintShipDao;

    @Resource
    CalibrationHouseSandDao houseSandDao;

    @Resource
    CalibrationShipSandDao shipSandDao;

    @Resource
    CalibrationWaterCleanPointDao waterCleanPointDao;

    @Resource
    CalibrationWaterCleanDao waterCleanDao;

    @Resource
    CalibrationWaterRustCleanDao waterRustCleanDao;

    @Resource
    CalibrationWaterCleanRustShipDao waterCleanRustShipDao;

    @Resource
    CalibrationAirPowerDao airPowerDao;

    @Resource
    ConfigDao configDao;

    /**
     * 一级界面
     * @return
     */
    public List<CalibrationStat> getStats() {

//        Integer year = DateUtils.getYear();
        int year = 2024;    // 碳排因子固定为2024年

        Double electric = 0.;
        Double gas = 0.;
        Double co2 = 0.;

        Double electricOcean = 0.;
        Double gasOcean = 0.;
        Double co2Ocean = 0.;

        List<ConfigEntity> configEntities = configDao.findByYear(year);
        for(ConfigEntity config : configEntities) {
            String name = config.getName();
            if(Constants.ENERGY_TYPE_SHENZHEN_ELECTRIC.equals(name)) {
                electric = config.getValue() / Constants.PARAM_CALIBRATION_TRANSFORMER_3;
            } else if (Constants.ENERGY_TYPE_SHENZHEN_CO2.equals(name)) {
                co2 = config.getValue();
            } else if (Constants.ENERGY_TYPE_SHENZHEN_GAS.equals(name)) {
                gas = config.getValue();
            } else if (Constants.ENERGY_TYPE_OCEAN_ELECTRIC.equals(name)) {
                electricOcean = config.getValue() / Constants.PARAM_CALIBRATION_TRANSFORMER_3;
            } else if (Constants.ENERGY_TYPE_OCEAN_GAS.equals(name)) {
                gasOcean = config.getValue();
            } else if (Constants.ENERGY_TYPE_OCEAN_CO2.equals(name)) {
                co2Ocean = config.getValue();
            }
        }

        List<CalibrationStat> result = new ArrayList<>();

        // 0 船体下料
        CalibrationShipCutDto ShipCutDto = calibrationService.calcShipCut();
        Double shipCutPowerUnit = ShipCutDto.getPowerUnit();
        Double shipCutPowerAirUnit = ShipCutDto.getPowerAirUnit();

        // 电能
        CalibrationStat shipCutStat1 = new CalibrationStat();
        shipCutStat1.setWork("船体下料");
        shipCutStat1.setChildWork("船体下料工序");
        shipCutStat1.setName("电能");
        shipCutStat1.setValue(shipCutPowerUnit);
        shipCutStat1.setSzRatio(electric);
        shipCutStat1.setRatio(electricOcean);
        shipCutStat1.setUnit("kwh");

        result.add(shipCutStat1);

        // 电能(压缩空气转化)
        CalibrationStat shipCutStat2 = new CalibrationStat();
        shipCutStat2.setWork("船体下料");
        shipCutStat2.setChildWork("船体下料工序");
        shipCutStat2.setName("电能(压缩空气转化)");
        shipCutStat2.setValue(shipCutPowerAirUnit);
        shipCutStat2.setSzRatio(electric);
        shipCutStat2.setRatio(electricOcean);
        shipCutStat2.setUnit("kwh");

        result.add(shipCutStat2);

        // 1 船体割旧
        CalibrationShipOldDto shipOldDto = calibrationService.calcShipOld();
        Double shipOldGasByUnit = shipOldDto.getGasByUnit() / Constants.PARAM_CALIBRATION_TRANSFORMER_1;      // 1.4 转换系数

        CalibrationStat shipOldStat1 = new CalibrationStat();
        shipOldStat1.setWork("船体割旧");
        shipOldStat1.setChildWork("船体割旧工序");
        shipOldStat1.setName("天然气");
        shipOldStat1.setValue(shipOldGasByUnit);
        shipOldStat1.setSzRatio(gas);
        shipOldStat1.setRatio(gasOcean);
        shipOldStat1.setUnit("kg");

        result.add(shipOldStat1);

        // 2 船体焊接
        CalibrationShipWeldDto shipWeldDto = calibrationService.calcShipWeld();
        Double shipWeldCo2ByUnit = shipWeldDto.getCo2ByUnit() / Constants.PARAM_CALIBRATION_TRANSFORMER_2;
        Double shipWeldPowerByUnit = shipWeldDto.getPowerByUnit();


        CalibrationStat shipWeldStat1 = new CalibrationStat();
        shipWeldStat1.setWork("船体焊接");
        shipWeldStat1.setChildWork("船体焊接工序");
        shipWeldStat1.setName("电能");
        shipWeldStat1.setValue(shipWeldPowerByUnit);
        shipWeldStat1.setSzRatio(electric);
        shipWeldStat1.setRatio(electricOcean);
        shipWeldStat1.setUnit("kwh");

        result.add(shipWeldStat1);

        CalibrationStat shipWeldStat2 = new CalibrationStat();
        shipWeldStat2.setWork("船体焊接");
        shipWeldStat2.setChildWork("船体焊接工序");
        shipWeldStat2.setName("CO2");
        shipWeldStat2.setValue(shipWeldCo2ByUnit);
        shipWeldStat2.setSzRatio(co2);
        shipWeldStat2.setRatio(co2Ocean);
        shipWeldStat2.setUnit("kg");

        result.add(shipWeldStat2);

        // 3 机电焊接
        CalibrationMachinePipeDto machinePipeDto = calibrationService.calcMachinePipe();
        Double falanPowerByUnit = machinePipeDto.getFalanPowerByUnit();
        Double wantouYahuPowerByUnit = machinePipeDto.getWantouYahuPowerByUnit();

        CalibrationStat machinePipeStat1 = new CalibrationStat();
        machinePipeStat1.setWork("机电管子焊接");
        machinePipeStat1.setChildWork("机电法兰焊接工序");
        machinePipeStat1.setName("电能");
        machinePipeStat1.setValue(falanPowerByUnit);
        machinePipeStat1.setSzRatio(electric);
        machinePipeStat1.setRatio(electricOcean);
        machinePipeStat1.setUnit("kwh");

        result.add(machinePipeStat1);

        CalibrationStat machinePipeStat2 = new CalibrationStat();
        machinePipeStat2.setWork("机电管子焊接");
        machinePipeStat2.setChildWork("机电弯头管子焊接工序");
        machinePipeStat2.setName("电能");
        machinePipeStat2.setValue(wantouYahuPowerByUnit);
        machinePipeStat2.setSzRatio(electric);
        machinePipeStat2.setRatio(electricOcean);
        machinePipeStat2.setUnit("kwh");

        result.add(machinePipeStat2);

        // 4 涂装喷漆
        // 4-1 喷漆房分段喷漆工序
        CalibrationPaintHouseDto paintHouseDto = calibrationService.calcPaintHouse();
        Double paintHousePowerByUnit = paintHouseDto.getPaintHousePowerByUnit();
        Double paintHouseAirPowerByUnit = paintHouseDto.getPaintHouseAirPowerByUnit();
        Double paintHouseGasByUnit = paintHouseDto.getPaintHouseGasByUnit() / Constants.PARAM_CALIBRATION_TRANSFORMER_1;

        CalibrationStat paintHouse1 = new CalibrationStat();
        paintHouse1.setWork("涂装喷漆");
        paintHouse1.setChildWork("喷漆房分段喷漆工序");
        paintHouse1.setName("电能");
        paintHouse1.setValue(paintHousePowerByUnit);
        paintHouse1.setSzRatio(electric);
        paintHouse1.setRatio(electricOcean);
        paintHouse1.setUnit("kwh");

        result.add(paintHouse1);

        CalibrationStat paintHouse2 = new CalibrationStat();
        paintHouse2.setWork("涂装喷漆");
        paintHouse2.setChildWork("喷漆房分段喷漆工序");
        paintHouse2.setName("电能(压缩空气转化)");
        paintHouse2.setValue(paintHouseAirPowerByUnit);
        paintHouse2.setSzRatio(electric);
        paintHouse2.setRatio(electricOcean);
        paintHouse2.setUnit("kwh");

        result.add(paintHouse2);

        CalibrationStat paintHouse3 = new CalibrationStat();
        paintHouse3.setWork("涂装喷漆");
        paintHouse3.setChildWork("喷漆房分段喷漆工序");
        paintHouse3.setName("天然气");
        paintHouse3.setValue(paintHouseGasByUnit);
        paintHouse3.setSzRatio(gas);
        paintHouse3.setRatio(gasOcean);
        paintHouse3.setUnit("kg");

        result.add(paintHouse3);

        // 4-2 舱室及船壳喷漆工序
        CalibrationPaintShipDto paintShipDto = calibrationService.calcPaintShip();
//        Double paintShipAirByUnit = paintShipDto.getPaintShipAirByUnit();
        Double paintShipAirPowerByUnit = paintShipDto.getPaintShipAirPowerByUnit();

        CalibrationStat paintShip1 = new CalibrationStat();
        paintShip1.setWork("涂装喷漆");
        paintShip1.setChildWork("舱室及船壳喷漆工序");
        paintShip1.setName("电能(压缩空气转化)");
        paintShip1.setValue(paintShipAirPowerByUnit);
        paintShip1.setSzRatio(electric);
        paintShip1.setRatio(electricOcean);
        paintShip1.setUnit("kwh");

        result.add(paintShip1);

        // 5 涂装打砂除锈
        // 5-1 打砂房分段打砂工序
        CalibrationHouseSandDto houseSandDto = calibrationService.calcHouseSand();
//        Double houseSandAirByUnit = houseSandDto.getHouseSandAirByUnit();
        Double houseSandPowerByUnit = houseSandDto.getHouseSandPowerByUnit();

        CalibrationStat houseSand1 = new CalibrationStat();
        houseSand1.setWork("涂装打砂除锈");
        houseSand1.setChildWork("打砂房分段打砂工序");
        houseSand1.setName("电能");
        houseSand1.setValue(houseSandPowerByUnit);
        houseSand1.setSzRatio(electric);
        houseSand1.setRatio(electricOcean);
        houseSand1.setUnit("kwh");

        result.add(houseSand1);

        // 5-2 舱室打砂工序
        CalibrationShipSandDto shipSandDto = calibrationService.calcShipSand();
//        Double shipSandAirByUnit = shipSandDto.getShipSandAirByUnit();
        Double shipSandAirPowerByUnit = shipSandDto.getShipSandAirPowerByUnit();

        CalibrationStat shipSand1 = new CalibrationStat();
        shipSand1.setWork("涂装打砂除锈");
        shipSand1.setChildWork("舱室打砂工序");
        shipSand1.setName("电能(压缩空气转化)");
        shipSand1.setValue(shipSandAirPowerByUnit);
        shipSand1.setSzRatio(electric);
        shipSand1.setRatio(electricOcean);
        shipSand1.setUnit("kwh");

        result.add(shipSand1);

        // 6 涂装清洁超水除锈
        // 6-1 超水清洁点打工序
        CalibrationWaterDto waterDto = calibrationService.calcWaterDto();
        Double waterPowerByUnit = waterDto.getWaterPowerByUnit();
        Double waterPointPowerByUnit = waterDto.getWaterPointPowerByUnit();
        Double waterRustPowerByUnit = waterDto.getWaterRustPowerByUnit();

        Double waterRustShipPowerByUnit = calibrationService.calcWaterRustShipDto().getWaterRustShipPowerByUnit();


        CalibrationStat waterCleanPoint1 = new CalibrationStat();
        waterCleanPoint1.setWork("涂装清洁超水除锈");
        waterCleanPoint1.setChildWork("超水清洁点打工序");
        waterCleanPoint1.setName("电能");
        waterCleanPoint1.setValue(waterPointPowerByUnit);
        waterCleanPoint1.setSzRatio(electric);
        waterCleanPoint1.setRatio(electricOcean);
        waterCleanPoint1.setUnit("kwh");

        result.add(waterCleanPoint1);

        // 6-2 超水清洁工序
        CalibrationStat waterClean1 = new CalibrationStat();
        waterClean1.setWork("涂装清洁超水除锈");
        waterClean1.setChildWork("超水清洁工序");
        waterClean1.setName("电能");
        waterClean1.setValue(waterPowerByUnit);
        waterClean1.setSzRatio(electric);
        waterClean1.setRatio(electricOcean);
        waterClean1.setUnit("kwh");

        result.add(waterClean1);

        // 6-3 超水除锈工序
        CalibrationStat waterRust1 = new CalibrationStat();
        waterRust1.setWork("涂装清洁超水除锈");
        waterRust1.setChildWork("超水除锈工序");
        waterRust1.setName("电能");
        waterRust1.setValue(waterRustPowerByUnit);
        waterRust1.setSzRatio(electric);
        waterRust1.setRatio(electricOcean);
        waterRust1.setUnit("kwh");

        result.add(waterRust1);

        // 6-4 舱盖超水除锈工序
        CalibrationStat waterRustShip = new CalibrationStat();
        waterRustShip.setWork("涂装清洁超水除锈");
        waterRustShip.setChildWork("舱盖超水除锈工序");
        waterRustShip.setName("电能");
        waterRustShip.setValue(waterRustShipPowerByUnit);
        waterRustShip.setSzRatio(electric);
        waterRustShip.setRatio(electricOcean);
        waterRustShip.setUnit("kwh");

        result.add(waterRustShip);


        return result;
    }


    // 0 - 船体下料   二级界面
    public Map<String, Object> shipCutSecond () {
        List<CalibrationShipCutReturnVO> allSipCuts = shipCutDao.findAllCuts();
        CalibrationShipCutDto shipCutDto = calibrationService.calcShipCut();

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, allSipCuts);
        map.put(STAT, shipCutDto);

        return map;
    }

    // 0 - 船体下料 三级界面
    public Map<String, Object> shipCutThird () {

        List<CalibrationShipCutReturnVO> allSipCuts = shipCutDao.findAllCuts();

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, allSipCuts);

        return map;
    }

    // 1 - 船体割旧 二级界面
    public Map<String, Object> shipOldSecond() {

        List<CalibrationShipOldReturnVO> allOld = shipOldDao.findAllOld();
        CalibrationShipOldDto shipOldDto = calibrationService.calcShipOld();

        Map<String, Object> map = new HashMap<>();

        map.put(DATA, allOld);
        map.put(STAT, shipOldDto);

        return map;
    }

    // 1 - 船体割旧 三级界面
    public Map<String, Object> shipOldThird() {

        List<CalibrationShipOldReturnVO> allOld = shipOldDao.findAllOld();

        Map<String, Object> map = new HashMap<>();

        map.put(DATA, allOld);

        return map;
    }

    // 2 船体焊接 二级界面
    public Map<String, Object> shipWeldSecond() {

        List<CalibrationShipWeldEntity> all = shipWeldDao.findAll();
        CalibrationShipWeldDto shipWeldDto = calibrationService.calcShipWeld();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();

        map.put(DATA, all);
        map.put(STAT, shipWeldDto);

        return map;
    }

    // 2 船体焊接 三级界面
    public Map<String, Object> shipWeldThird() {

        List<CalibrationShipWeldEntity> all = shipWeldDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();

        map.put(DATA, all);

        return map;
    }

    // 3 机电管子 二级界面
    public Map<String, Object> machinePipeSecond(String type, String method) {

        CalibrationMachinePipeEntity entity = new CalibrationMachinePipeEntity();
        entity.setType(type);
        if(ObjectUtils.isNotEmpty(method)) {
            entity.setMethod(method);
        }
        Example example = Example.of(entity);
        List<CalibrationMachinePipeEntity> all = machinePipeDao.findAll(example);

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        CalibrationMachinePipeDto machinePipeDto = calibrationService.calcMachinePipe();


        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, machinePipeDto);

        return map;
    }

    // 4 - 0 涂装喷漆 - 喷漆房 二级界面
    public Map<String, Object> paintHouseSecond() {

        List<CalibrationPaintHouseEntity> all = paintHouseDao.findAll();

        CalibrationPaintHouseDto paintHouseDto = calibrationService.calcPaintHouse();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, paintHouseDto);

        return map;
    }

    // 4 - 0 涂装喷漆 - 喷漆房 三级界面
    public Map<String, Object> paintHouseThird() {

        List<CalibrationPaintHouseEntity> all = paintHouseDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;
    }

    // 4 - 1 涂装喷漆 - 舱室打砂  二级界面
    public Map<String, Object> paintShipSecond() {

        List<CalibrationPaintShipEntity> all = paintShipDao.findAll();

        CalibrationPaintShipDto paintShipDto = calibrationService.calcPaintShip();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, paintShipDto);

        return map;
    }

    // 4 - 1 涂装喷漆 - 舱室打砂  三级界面
    public Map<String, Object> paintShipThird() {

        List<CalibrationPaintShipEntity> all = paintShipDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;
    }

    // 5 - 0 打砂除锈 - 打砂房  二级界面
    public Map<String, Object> sandHouseSecond() {

        List<CalibrationHouseSandEntity> all = houseSandDao.findAll();

        CalibrationHouseSandDto houseSandDto = calibrationService.calcHouseSand();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, houseSandDto);

        return map;
    }

    // 5 - 0 打砂除锈 - 打砂房  三级界面
    public Map<String, Object> sandHouseThird() {

        List<CalibrationHouseSandEntity> all = houseSandDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;
    }

    // 5-1 打砂除锈 - 舱室打砂 二级界面
    public Map<String, Object> sandShipSecond() {

        List<CalibrationShipSandEntity> all = shipSandDao.findAll();

        CalibrationShipSandDto shipSandDto = calibrationService.calcShipSand();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, shipSandDto);

        return map;
    }

    // 5-1 打砂除锈 - 舱室打砂 三级界面
    public Map<String, Object> sandShipThird() {

        List<CalibrationShipSandEntity> all = shipSandDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;
    }

    // 6-0 超水清洁 二级界面
    public Map<String, Object> waterCleanSecond() {

        List<CalibrationWaterCleanEntity> all = waterCleanDao.findAll();
        CalibrationWaterCleanDto waterCleanDto = calibrationService.calcWaterCleanDto();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, waterCleanDto);

        return map;

    }

    // 6-0 超水清洁 三级界面
    public Map<String, Object> waterCleanThird() {

        List<CalibrationWaterCleanEntity> all = waterCleanDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;

    }

    // 6-1 超水清洁点打 二级界面
    public Map<String, Object> waterCleanPointSecond() {

        List<CalibrationWaterCleanPointEntity> all = waterCleanPointDao.findAll();
        CalibrationWaterCleanPointDto waterCleanPointDto = calibrationService.calcWaterCleanPointDto();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, waterCleanPointDto);

        return map;

    }

    // 6-1 超水清洁点打 三级界面
    public Map<String, Object> waterCleanPointThird() {

        List<CalibrationWaterCleanPointEntity> all = waterCleanPointDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;
    }

    // 6-2 超水除锈 二级界面
    public Map<String, Object> waterCleanRustSecond() {

        List<CalibrationWaterRustCleanEntity> all = waterRustCleanDao.findAll();
        CalibrationWaterCleanRustDto waterCleanRustDto = calibrationService.calcWaterRustDto();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, waterCleanRustDto);

        return map;

    }

    // 6-1 超水清洁点打 三级界面
    public Map<String, Object> waterCleanRustThird() {

        List<CalibrationWaterRustCleanEntity> all = waterRustCleanDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;
    }

    /////////////////////////////////////////
    // 6-2 舱盖超水除锈 二级界面
    public Map<String, Object> waterCleanRustShipSecond() {

        List<CalibrationWaterCleanRustShipEntity> all = waterCleanRustShipDao.findAll();
        CalibrationWaterCleanRustShipDto waterCleanRustDto = calibrationService.calcWaterRustShipDto();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
            t.setInner(null);
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, waterCleanRustDto);

        return map;

    }

    // 6-2 舱盖超水除锈 三级界面
    public Map<String, Object> waterCleanRustShipThird() {

        List<CalibrationWaterCleanRustShipEntity> all = waterCleanRustShipDao.findAll();

        all.forEach(t-> {
            t.setShipId(t.getShip().getId());
            t.setShipName(t.getShip().getName());
        });

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);

        return map;
    }


    /**
     * 压缩空气气电转换标定统计表
     *
     * @return
     */
    public Map<String, Object> unitAirPower() {

        List<CalibrationAirPowerEntity> all = airPowerDao.findAll();

        Double unitAirPower = calibrationService.calcUnitAirPower();

        Map<String, Object> map = new HashMap<>();
        map.put(DATA, all);
        map.put(STAT, unitAirPower);

        return map;
    }


}
